That seems to have helped now I think i just need to adjust the payload i am sending
{'condition': ['and', ['contains', ['path', 'payload', 'source'], 'website']], 'actions': [['route', 'P2KGCOP'], ['suppress', False], ['severity', 'info']]}
<class 'dict'>
################ create-eventrule.py #################
Response Status: 400
b'{"error":"Bad Request"}'
updated code
#! /usr/bin/python3
import requests
authorization_token = '##########################'
pagerduty_session = requests.Session()
pagerduty_session.headers.update({
'Authorization': 'Token token=' + authorization_token,
'Content-Type': 'application/json',
'Accept': 'application/vnd.pagerduty+json;version=2'
})
# PagerDuty API Endpoint for event rules
url = 'https://api.pagerduty.com/event_rules'
# Data payload
data = {"condition": ["and",["contains",["path","payload","source"],"website"]], "actions": [["route","P2KGCOP"],["suppress",False],["severity","info"]]}
print(data)
print(type(data))
# Response
response = pagerduty_session.post(url, data=data, headers=pagerduty_session.headers)
print("\n################ create-eventrule.py #################\n")
# Print status and body of response
print('Response Status:', response.status_code)
if response.status_code != 200:
print(response.content)
raise SystemExit(1)